#ifndef chess_h
#define chess_h


/*
 * Chessboard squares.
 *
 *        A   B   C   D   E   F   G   H
 * ------------------------------------------
 *  8 |  56  57  58  59  60  61  62  63  | 8
 *  7 |  48  49  50  51  52  53  54  55  | 7
 *  6 |  40  41  42  43  44  45  46  47  | 6
 *  5 |  32  33  34  35  36  37  38  39  | 5
 *  4 |  24  25  26  27  28  29  30  31  | 4
 *  3 |  16  17  18  19  20  21  22  23  | 3
 *  2 |   8   9  10  11  12  13  14  15  | 2
 *  1 |   0   1   2   3   4   5   6   7  | 1
 * ------------------------------------------
 *        A   B   C   D   E   F   G   H
 */


enum squares {
  A1 = 0, B1, C1, D1, E1, F1, G1, H1,
  A2, B2, C2, D2, E2, F2, G2, H2,
  A3, B3, C3, D3, E3, F3, G3, H3,
  A4, B4, C4, D4, E4, F4, G4, H4,
  A5, B5, C5, D5, E5, F5, G5, H5,
  A6, B6, C6, D6, E6, F6, G6, H6,
  A7, B7, C7, D7, E7, F7, G7, H7,
  A8, B8, C8, D8, E8, F8, G8, H8
};


// colors
#define WHITE 0
#define BLACK 1

// colorless pieces
#define PAWN 0
#define KNIGHT 1
#define BISHOP 2
#define ROOK 3
#define QUEEN 4
#define KING 5
#define EMPTY 6

// castling capabilities
#define WCASTLE_SHORT 1
#define WCASTLE_LONG 2
#define BCASTLE_SHORT 4
#define BCASTLE_LONG 8

// en passant (0-63) specify the en passant square
#define NO_ENPASSANT 64

// index/coordinates conversion
#define SQUARE(file, rank) ((file) + ((rank) << 3))
#define RANK(square) ((square) >> 3)
#define FILE(square) ((square) & 7)


// directions
#define EAST 0
#define NORTH_EAST 1
#define NORTH 2
#define NORTH_WEST 3
#define WEST 4
#define SOUTH_WEST 5
#define SOUTH 6
#define SOUTH_EAST 7
#define NULL_DIRECTION 8

#define OPP_DIRECTION(d) (((d) + 4) & 7)
#define DIR_IS_DIAGONAL(d) ((d) & 1)

#endif  // chess_h
